<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="icon" href="images/icone_site/favicon.jpg">
	<title>Gamekillers - Proposer un article</title>
	<script type="text/javascript" src="ckeditor/ckeditor.js"></script>

	<!-- Bootstrap -->
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="css/bootstrap-inputs-min.css" rel="stylesheet">

	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
	<link href="css/complement.css" rel="stylesheet">
</head>
<body>
<?php
		include_once("accessoires/header.html");
		include_once("accessoires/menu.html");
	?>
	<div class="page">		
			<h3 class="underline">
				<?php if(isset ($_GET['article'])){?>
				Modifier un article
				<?php } else{ ?>
				Poster un article
				<?php }?>
		</h3>
			<form class="form-horizontal" action="edit_article.php<?php if (isset ($_GET['article']))echo "?article=".$id_article;?>" method="POST" enctype="multipart/form-data">
				<div class="col-sm-10">
					<div class="form-group">
						<label for="inputArticleTitle" class="col-sm-2 control-label">Titre de l'article</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="inputArticleTitle"  name="title_article" value="<?php if(isset($title_article))echo $title_article; ?>" required="required">
							<?php if(isset($errors_article[1])) { ?>
							<div class="alert alert-danger alert-dismissible" role="alert" style="margin-bottom: 0">
								<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
								<strong><span class="glyphicon glyphicon-alert" aria-hidden="true"></span>&nbsp;</strong><?php echo $errors_article[1];?>
							</div>
							<?php } ?>
						</div>
					</div>
					<div class="form-group">
						<label for="editor1" class="col-sm-2 control-label">Contenu</label>
						<div class="col-sm-10">
							<?php if(isset($errors_article[2])) { ?>
							<div class="alert alert-danger alert-dismissible" role="alert" style="margin-bottom: 0">
								<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
								<strong><span class="glyphicon glyphicon-alert" aria-hidden="true"></span>&nbsp;</strong><?php echo $errors_article[2];?>
							</div>
							<?php } ?>
							<textarea id="editor1" name="text_article" required="required"><?php if(isset($text_article)) echo $text_article; ?></textarea>
							<script type="text/javascript">
								CKEDITOR.replace( 'editor1',{
									height: '200px',
									toolbar: [
										{ name: 'document', items: [ 'Source']},
										{ name: 'view', items: ['Preview','-','Maximize','ShowBlocks','CreateDiv']},
										{ name: 'basicstyles', items: [ 'Bold', 'Italic','Strike','Underline', '-', 'RemoveFormat'  ] },
										{ name: 'styles', items: [ 'Font', 'FontSize' ] },
										{ name: 'insert', items: [ 'Smiley', 'SpecialChar' ,'CodeSnippet', 'EqnEditor'] },
										{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'SelectAll', '-', 'Scayt' ] },
										{ name: 'colors', items: [ 'TextColor', 'BGColor'] },
										{ name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
										{ name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak', 'Iframe' ] },
										{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl' ] },
									]
								} );
							</script>
						</div>
					</div>
					<div class="form-group">
						<span class="col-sm-2"></span>
						<div class="col-sm-10">
							<?php if(isset($errors_article[3])) { ?>
							<div class="alert alert-danger alert-dismissible" role="alert" style="margin-bottom: 0">
								<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
								<strong><span class="glyphicon glyphicon-alert" aria-hidden="true"></span>&nbsp;</strong><?php echo $errors_article[3];?>
							</div>
							<?php } ?>
							<p>Activer les commentaires : </p>
							<div class='input'>
								<input type='radio' value='1' id='input5' name='com_allowed' <?php if(isset ($_GET['article'])){ if($com_allowed==1){echo 'checked';}}else{echo 'checked';} ?> required>
								<label for="input5">Oui</label>
								<input type='radio' value='0' id='input6' name='com_allowed' <?php if(isset ($_GET['article'])){ if($com_allowed==0){echo 'checked';}} ?> required>
								<label for="input6">Non</label>
							</div>
						</div>
					</div>
				</div>
				<div class="col-sm-2">
					<div class="form-group">
						<label for="inputtype" class="control-label">Type d'article</label>
						<select id="inputtype" class="form-control" name="libelle">
							<?php $i=0; while (isset($libelle[$i])){ ?>
							<option <?php if(isset($_GET['article'])){ if ($type_article==$id_type[$i]){ echo 'selected="selected"';} }?> >
							<?php echo $libelle[$i]; ?>
							</option>
							<?php $i++; } ?>
						</select>
					</div>
					<div class="form-group">
						<label for="inputArticleFile" class="control-label">Image de l'article</label>
						<label for="inputArticleFile"><img id="blah" class="img-responsive img-rounded" src="<?php if(isset($image_article)) {echo $image_article;}else{echo 'images/articles/defaut_article.png';} ?>" height="200" style="padding-top: 5px;padding-bottom: 5px;cursor: pointer;" /></label>
						<input onchange="readURL(this);" type="file" name="inputArticleFile" class="form-control filestyle" id="inputArticleFile" style="width: 100%;" accept="image/*" data-input="false" data-buttonText="&nbsp;Parcourir" /> <span style="font-size: 12px;">(500 Ko Max)</span>
						<?php if(isset($errors_article[4])) { ?>
						<div class="alert alert-danger alert-dismissible" role="alert" style="margin-bottom: 0">
							<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
							<strong><span class="glyphicon glyphicon-alert" aria-hidden="true"></span>&nbsp;</strong><?php echo $errors_article[4];?>
						</div>
						<?php } ?>
					</div>
				</div>
				<div class="col-sm-offset-2 col-sm-10">
					<div class="form-group">
						<p>
							<input class="btn btn-default" type="submit"
							<?php if(isset($_GET['article'])){ ?> value=" Modifier " name="modifier"
							<?php }else{ ?> value=" Poster " name="poster" <?php } ?>
							/>
						</p>
					</div>
				</div>
			</form>
	</div>
	<?php
		include_once("accessoires/footer.html");
	?>
<!--read url pour l'image-->
<script type="text/javascript" src="js/readURL.js"></script>
<!-- jQuery -->
<script src="js/jquery-2.1.3.min.js"></script>
<!-- bootstrap js-->
<script src="js/bootstrap.min.js"></script>
<!-- compteur -->
<script type="text/javascript" src="js/compteur.js"></script>
<!--Filestyle-->
<script src="js/bootstrap-filestyle.min.js"></script>
<!---input-->
<script type="text/javascript" src='js/inputs-min.js'></script>
</body>
</html>